<template>
<div>
  <!--     面包屑导航区域-->
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>商品管理</el-breadcrumb-item>
    <el-breadcrumb-item>商品列表</el-breadcrumb-item>
  </el-breadcrumb>
  <!--  卡片区域-->
  <el-card>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-input placeholder="请输入内容" v-model="input1"
        class="input-with-select"
        >
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </el-col>
      <el-col :span="4">
        <el-button @click="goAdd"  type="primary">添加商品</el-button>
      </el-col>
    </el-row>
    <el-table :data="list" border stripe>
      <el-table-column type="index" label="#"></el-table-column>
      <el-table-column label="商品名称" prop="goods_name"></el-table-column>
      <el-table-column width="120px" label="商品价格（元）" prop="goods_price"></el-table-column>
      <el-table-column width="120px" label="商品重量" prop="goods_weight"></el-table-column>
      <el-table-column label="创建时间" prop="add_time">
        <template slot-scope="scope">
          {{scope.row.add_time | dateFormat}}
        </template>
      </el-table-column>
      <el-table-column label="操作" prop="">
        <template>
          <el-button size="mini" type="primary" icon="el-icon-edit">编辑</el-button>
          <el-button size="mini" type="danger" icon="el-icon-delete">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination>
  </el-card>
</div>
</template>

<script>
export default {
  name: 'index',
  created () {
    this.getList()
  },
  data () {
    return {
      input1: '',
      list: [],
      currentPage4: 1
    }
  },
  methods: {
    getList () {
      // 获取数据列表
      const data = [{
        good_id: 926,
        goods_name: '啊回复啊舒k放假啊放假啊索尼发布是否·服啊个好友',
        goods_price: 1,
        goods_number: 1,
        goods_weight: 2,
        add_time: 1645684677,
        upd_time: 1645684677,
        hot_number: 0,
        is_promote: false
      }]
      this.list = data
    },
    handleSizeChange (newSize) {
      console.log(newSize)
    },
    handleCurrentChange (newPage) {
      console.log(newPage)
    },
    goAdd () {
      this.$router.push('/goods/add')
    }
  }
}
</script>

<style scoped>

</style>
